﻿using System.Collections.Generic;
using ZilLion.Task.Domain.Taskmanager.Entity;
using ZilLion.Task.Domain.Taskmanager.Repository;

namespace ZilLion.Task.Domain.Taskmanager.Service
{
    public class TaskModuleConfigService : BaseService, ITaskModuleConfigService
    {
        private readonly ITaskModuleConfigRespository _taskModuleConfigRespository;

        public TaskModuleConfigService(ITaskModuleConfigRespository taskModuleConfigRespository)
        {
            _taskModuleConfigRespository = taskModuleConfigRespository;
        }

        public IEnumerable<TaskModuleConfigEntity> GetTaskModules()
        {
            var response = _taskModuleConfigRespository.GetTaskModuleConfig();
            if (response != null)
            {
                var entitys = response.TaskModuleList;
                return entitys;
            }
            return new List<TaskModuleConfigEntity>();
        }

        public string UploadPackage(string path)
        {
            var response = _taskModuleConfigRespository.UpLoadPackageFile(path);
            if (response != null)
                return response.PackageKey;
            return string.Empty;
        }

        public bool SaveTaskModuleConfig(TaskModuleConfigEntity entity)
        {
            return _taskModuleConfigRespository.SaveTaskModuleConfig(entity);
        }
    }
}